package com.example.administrator.xinyutg.activity;

import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;

import com.example.administrator.xinyutg.R;
import com.example.administrator.xinyutg.utils.FirstUtil;

public class SplashActivity extends ActionBarActivity {

    private ImageView iv;
    private Handler handler=new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what){
                case 1:
                    Intent intent=new Intent(SplashActivity.this,GuideActivity.class);
                    startActivity(intent);
                    break;
                case 2:
                    Intent intent1=new Intent(SplashActivity.this,MainActivity.class);
                    startActivity(intent1);
                    break;
            }
        }
    };


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        initView();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Message message=Message.obtain();
                if (FirstUtil.isFirst(SplashActivity.this)){
                    message.what=1;
                }else {
                    message.what=2;
                }
                handler.sendMessage(message);
            }
        },2*1000);

    }

    private void initView() {
        iv = (ImageView) findViewById(R.id.iv_splash);
    }


}
